﻿using System;
using System.Windows.Input;

namespace OperGui.ViewModel
{
    /// <summary>
    /// Represents an actionable item displayed by a View.
    /// </summary>
    public class CommandViewModel : ViewModelBase
    {
        
        public CommandViewModel(string displayName,string type, ICommand command)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            
            DisplayName = displayName;
            Command = command;
            TType = type;
            ID = tailor(DisplayName);
        }

        public string ID { get; set; }
        public ICommand Command { get; private set; }
        public string DisplayName { get; protected set; }
        public string TType { get; set; }


        string tailor(string DisplayName)
        {
            if (DisplayName.LastIndexOf("/") > -1)
            {
                DisplayName = DisplayName.Substring(DisplayName.LastIndexOf("/") + 1);
            }
            if (DisplayName.LastIndexOf("/") > -1)
            {
                DisplayName = DisplayName.Substring(DisplayName.LastIndexOf("/") + 1);
            }
            if (DisplayName.LastIndexOf("/") > -1)
            {
                DisplayName = DisplayName.Substring(DisplayName.LastIndexOf("/") + 1);
            }
            if (DisplayName.LastIndexOf("/") > -1)
            {
                DisplayName = DisplayName.Substring(DisplayName.LastIndexOf("/") + 1);
            }

            return DisplayName;
        }
    }
}